from pathlib import Path
import scrapy


class ItcastSpider(scrapy.Spider):
    name = "itcast"
    start_urls = ['https://quotes.toscrape.com/page/1/','https://quotes.toscrape.com/page/2/']

    def parse(self, response):
        page = response.url.split("/")[-2]
        filename = f"quotes-{page}.html"
        Path(filename).write_bytes(response.body)
        self.log(f"Saved file {filename}")
